home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13986 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: li.net!jeremy
  2. From: jeremy@newshost.li.net (Jeremy Markman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Please help w/seemingly simple problem...
  5. Date: 11 Apr 1996 01:51:26 GMT
  6. Organization: LI Net (Long Island Network)
  7. Distribution: world
  8. Message-ID: <4khoiu$5v3@linet06.li.net>
  9. References: <4ke19f$m6r@freenet.vcu.edu>
  10. NNTP-Posting-Host: linet01.li.net
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. damurr@freenet.vcu.edu wrote:
  14. : BTW- I'm using Borland Turbo C++ 1.0
  15.  
  16. : -------------------------------------------------------------------------
  17.  
  18. : [ SOURCE START ]
  19.  
  20. :    #define string "\r"
  21. :        scanf(string);
  22.  
  23. :     if (string="\r"");
  24. :     {
  25. :         clrscr();
  26. :         printf("                    - Options Menu - \n\n");
  27. :     }
  28.  
  29. Use getch() instead of scanf.  This will read in each character as you 
  30. type it, without echoing the character to the screen.  Then, you have 
  31. full control over what you want to do...
  32. Also, you cannot compare strings by testing for equality, you'd have to 
  33. use strcmp().  When testing character or number equality, use =, not ==.  
  34. Anyhow, in this case you don't want to compare a string anyway, you want 
  35. to compare a character...see the code snippet below...
  36.  
  37.  
  38. char ch;
  39.  
  40. if ((ch = getch()) == 0)   {* This statement helps trap functions keys *}
  41.   ch = getch();                   
  42.  
  43. if (ch == '\n')
  44.  {
  45.   clrscr();
  46.   printf("Options Menu\n");
  47.  }
  48.